package com.horoscope.astrology.zodiac.signs.free.network

import com.horoscope.astrology.zodiac.signs.free.MmoApplication
import com.horoscope.astrology.zodiac.signs.free.bean.*
import com.horoscope.astrology.zodiac.signs.free.network.task.*

/**
 *  Retrofit③
 *  定义所有的接口调用方法
 * */
object NetworkEngine {

    private fun getDeviceId(): String = MmoApplication.getInstance().getAdvertisingId()
    /**
     * 1.任务列表接口
     * */
    /* fun getOffersRx(ad_id: String, listener: NetworkListener<GetOfferBean>) {
         val udid = getDeviceId()
         val ad_id = AdvertisingIdClient.getGoogleAdId(MmoApplication.getInstance().applicationContext)
         val osVersion = android.os.Build.VERSION.RELEASE
         val ip = GetLocalIp.getLocalIp()
         val platform = "android"
         GetOfferTask(udid, ad_id, osVersion, ip, platform, listener)
     }*/
    fun getZodiacCompatibility(
        h1: String,
        h2: String,
        listener: NetworkListener<ZodiacResultBean>
    ) {
        GetZodiacResultTask(h1, h2, listener)
    }

    fun getLoveResult(h1: String, h2: String, listener: NetworkListener<LoveResultBean>) {
        GetLoveResultTask(h1, h2, listener)
    }

    @Deprecated("use getMainData")
    fun getHomeData(
        gender: String,
        birthday: String,
        marial: String,
        listener: NetworkListener<DataResultBean>
    ) {
        GetDataTask(getDeviceId(), gender, birthday, marial, listener)
    }

    fun getMainData(horoscope: String, listener: NetworkListener<DataResultBean>) {
        GetMainDataTask(horoscope, listener)
    }

    fun getHoroscopeData(horoscope: String, listener: NetworkListener<HoroscopeDataBean>) {
        GetHoroscopeDataTask(horoscope, listener)
    }

    fun getNumber(
        gender: String,
        birthday: String,
        status: String,
        listener: NetworkListener<NumBerResultBean>
    ) {
        GetNumberTask(getDeviceId(), gender, birthday, status, listener)
    }


    fun getConfig(listener: NetworkListener<ConfigResultBean>) {
        GetConfigTask(listener)
        //HttpEngine().setNeedDecode(true)
    }

    fun getNews(category: String, page: String, listener: NetworkListener<ArticleResultBean>) {
        GetNewsTask(category, page, listener)
    }

    fun getQuiz(type: String, page: String, listener: NetworkListener<QuizResultBean>) {
        GetQuiz(type, page, listener)
    }

    fun getNameResult(name1: String, name2: String, listener: NetworkListener<NameResultBean>) {
        GetNameResultTask(name1, name2, listener)
    }

//    fun getPushNews(listener: NetworkListener<PushNewBean>) {
//        GetPushNewsTask(listener)
//    }

    fun postUserInfo(
        name: String,
        gender: String,
        birthday: String,
        place: String,
        status: String,
        listener: NetworkListener<BaseBean>
    ) {
        PostUserInfo(getDeviceId(), name, gender, birthday, place, status, listener)
    }


    fun getCityResult(
        startWith: String,
        listener: NetworkListener<CityResultBean>?
    ) {
        GetCityResult(startWith, "p", "full", 20, "birthreport", "", listener)
    }

    fun postFCMToken(
        token: String,
        horoscope: String,
        timeZone: String,
        listener: NetworkListener<FCMResultBean>?
    ) {
        val udid = getDeviceId()
        PostFCMTokenTask(udid, token, horoscope, timeZone, listener)
    }


    fun getBirthChart(
        name: String,
        north: String,
        west: String,
        offset: Int,
        birthday: String,
        bornPlace: String,
        timezone: String,
        listener: NetworkListener<BirthChartResultBean>?
    ) {
        val udid = getDeviceId()
        GetBirthChartTask(udid, name, north, west, offset, birthday, bornPlace, timezone, listener)

    }

    fun getRelationResult(
        name1: String,
        birthday1: String,
        gender1: String,
        name2: String,
        birthday2: String,
        gender2: String,
        listener: NetworkListener<RelationResultBean>?
    ) {
        val udid = getDeviceId()
        GetRelationResultTask(udid, name1, birthday1, gender1, name2, birthday2, gender2, listener)
    }


//    /**
//     * 9 反作弊数据收集接口
//     *
//     */
//    fun postCollectInfo(
//        charge: Int,
//        brightness: Float,
//        gyroscope: String,
//        wifi: Int,
//        listener: NetworkListener<BaseBean>?
//    ) {
//        val udid = getDeviceId()
//        PostCollectInfoWithTask(
//            charge,
//            udid,
//            brightness,
//            gyroscope,
//            wifi,
//            listener
//        )
//    }
//
//    /**
//     * 10 签到成功回调接口
//     */
//    fun postSign(
//        code: String,
//        is_double: String = "0",
//        listener: NetworkListener<BaseBean>
//    ) {
//        val udid = getDeviceId()
//        PostSign(udid, code, is_double, listener)
//    }
//
//
//    /**
//     * 14 看视频获取金币
//     */
//    fun postRewardCoin(
//        data: String, listener: NetworkListener<BaseBean>
//    ) {
//        PostCoinTask(data, listener)
//    }

    // 上传文章标题
    fun postArticleTitle(
        title: String,
        listener: NetworkListener<BaseBean>?
    ) {
        val udid = getDeviceId()
        PostArticleTitleTask(udid, title, listener)
    }

//    // 更新User
//    fun postUpdateUser(
//        name: String,
//        gender: String,
//        birthday: String,
//        born_place: String,
//        marital_status: String,
//        listener: NetworkListener<BaseBean>?
//    ) {
//        val udid = getDeviceId()
//        PostUpdateUserTask(udid, name, gender, birthday, born_place, marital_status, listener)
//    }

    // 更新User单个字段
    fun postUpdateUserForKey(
        type: String,
        info: String,
        listener: NetworkListener<BaseBean>?
    ) {
        val udid = getDeviceId()
        PostUpdateUserForKeyTask(udid, type, info, listener)

    }

    // 根据push获取文章详情页
    fun getArticleForPushUrl(
        article: String,
        url: String,
        listener: NetworkListener<PushNewBean>
    ) {
        GetArticleForPushUrlTask(article, url, listener)

    }

    // 根据push获取文章详情页
    fun getQuizForPushUrl(
        quizid: String,
        url: String,
        listener: NetworkListener<QuizResultBean>
    ) {
        GetQuizForPushUrlTask(quizid, url, listener)

    }

    // 获取每日数字具体释义
    fun getNumberText(
        type: Int,
        number: Int,
        listener: NetworkListener<NumerologyBean>?
    ) {
        GetNumberTextTask(type, number, listener)
    }

    // 获取每日数字具体释义
    fun getCharacter(
        horoscope: String,
        listener: NetworkListener<CharacterBean>?
    ) {
        GetCharacterTask(horoscope, listener)
    }

    // 手相
    fun getPalmScanResult(
        horoscope: String,
        data: String,
        listener: NetworkListener<HandBean>?
    ) {
        GetPalmScanResultTask(horoscope, data, listener)
    }
}